package com.projectxxxxxxxxxx.utils;


import java.text.SimpleDateFormat;
import java.util.Date;

public abstract class UiUtils {

	public static String humanReadableByteCount(long bytes, boolean si) {
		// boolean si = false;
		int unit = si ? 1000 : 1024;
		if (bytes < unit) return bytes + " B";
		int exp = (int) (Math.log(bytes) / Math.log(unit));
		String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
		return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
	}

	public static String dateFormat(Date visited) {
		SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss");// "dd-MM-yy");
		return sdf.format(visited);
	}

}
